package com.ic.es.controller;


import com.IC.domain.vo.AccessControlRecordVO;
import com.ic.es.service.EsAccessRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/access")
public class EsAccessRecordController {
    private final EsAccessRecordService accessRecordService;

    @Autowired
    public EsAccessRecordController(EsAccessRecordService accessRecordService) {
        this.accessRecordService = accessRecordService;
    }

    @GetMapping("/access-record")
    public void indexAccessRecord() {
        accessRecordService.createNewIndex();
    }

    /**
     * 批量添加门禁记录
     */
    @PostMapping("/add")
    public void indexAccessRecords(@RequestBody List<AccessControlRecordVO> records) {
        accessRecordService.bulkRecords(records);
    }


    /**
     * 批量添加人口、住宅、车辆
     */
    @PostMapping("/addList")
    public void indexList(@RequestBody List<Map> list) {
        accessRecordService.bulkList(list);
    }

}
